var db = require('../tools/db');

function _checkAuth(slug, password, callback) {
    if (!slug || !password) {
        return callback('用户名和密码不能为空', []);
    }
    db.exec('select * from author where aor_slug = ? and aor_password = ?', [slug, password], function(err, r) {
        if (!r || r.length < 1) {
            err = '用户名或者密码错误 ';
        }
        callback(err, r);
    });
}

function _findById(id, callback) {
    db.exec('select * from author where aor_id = ?', [id], function(err, r) {
        callback(err, r);
    });
}

//检查用户名密码
exports.checkAuth = _checkAuth;
//根据id查找author
exports.findById = _findById;